import * as API from '../axios';
import * as util from "@/common/util";

export default {

    //订单列表
    getOrderList: (params, page) => {
        const url = util.replacePageNumAndSize('/manage/orders/{pageNum}/{pageSize}', page)
        return API.axiosGetAPI(url, params)
    },
    //订单详情
    orderDetail: orderNo => {
        return API.axiosGetAPI(`/manage/orders/${orderNo}`)
    },
    //订单-时间线
    orderRecord: orderNo => {
        return API.axiosGetAPI(`/manage/orders/operation-record/${orderNo}`)
    },
    //订单退款
    orderRefund: params => {
        const headers = {
            'lang-key': 'Order_Refund'
        }
        return API.axiosPutAPI('/manage/orders/refund', params, headers);
    },
    //订单修改-优惠/免单
    orderState: params => {
        const headers = {
            'lang-key': params.state == 1 ? 'Order_cancellation' : (params.state == 2 ? 'Order_discounts' : 'Order_freeCharge')
        }
        return API.axiosPutAPI('/manage/orders/state', params, headers);
    },
    //订单结束
    orderEnd: id => {
        const headers = {
            'lang-key': 'Order_End_order'
        }
        return API.axiosPutAPI(`/manage/orders/end/${id}`, '', headers);
    },
    //手动扣费
    orderDeduction: orderNo => {
        const headers = {
            'lang-key': 'Order_Status_deduct'
        }
        return API.axiosPostAPI(`/manage/orders/manual-deduction/${orderNo}`, '', headers);
    },
    //获取订单问题列表
    getReportsList: (params, page) => {
        const url = util.replacePageNumAndSize('/manage/order-reports/{pageNum}/{pageSize}', page)
        return API.axiosGetAPI(url, params)
    },
    //检查充电宝
    checkDevice: params => {
        return API.axiosGetAPI(`/manage/orders/device/check`, params)
    },
    //获取报订单问题
    getReportsDetail: orderNo => {
        return API.axiosGetAPI(`/manage/order-reports/problem/${orderNo}`)
    },
    //处理订单问题反馈
    auditOrder: params => {
        const headers = {
            'lang-key': 'Handle'
        }
        return API.axiosPutAPI('/manage/order-reports/audit', params, headers);
    },

    //获取用户反馈列表
    getFeedbackList: (params, page) => {
        const url = util.replacePageNumAndSize('/manage/feedback/{pageNum}/{pageSize}', page)
        return API.axiosGetAPI(url, params)
    },

    //处理用户反馈
    auditUser: params => {
        const headers = {
            'lang-key': 'Handle'
        }
        return API.axiosPutAPI('/manage/feedback/state', params, headers);
    },


    // 财务概览-订单营收
    getPageFinanceOverviewOrder: (params, page) => {
        const url = util.replacePageNumAndSize('/manage/transfers/revenue/{pageNum}/{pageSize}', page)
        return API.axiosGetAPI(url, params);
    },
    //财务概览-订单营收-统计
    getTotalFinanceOverviewOrder: (params) => {
        return API.axiosGetAPI('/manage/transfers/revenue/statistics', params);
    },

    //订单列表-商家订单流水导出
    getExportOrder: (params) => {
        const headers = {'content-Type':'application/x-www-form-urlencoded',
        'lang-key': 'exports' }
        return API.axiosPostAPI(`/manage/orders/order/export?paymentState=${params.paymentState}&search=${params.search}&source=${params.source}&rangeTime=${params.rangeTime}&state=${params.state}`, null, headers, {
            responseType: 'blob'
        });
    },        
}